home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0001_BOOKISBN.PAS.pas next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  41 lines

  1. {
  2.  For you Programming librarians: the following Turbo Pascal Program
  3.  will verify any ISBN (International Standard Book Number).
  4. }
  5. (*******************************************************************)
  6.  Program VerifyISBN;    { Verify any ISBN number. Turbo Pascal      }
  7.                         { 1992, 1993 Greg Vigneault                 }
  8.  
  9.  Var    ISBNstr                     : String[16];
  10.         loopc, ISBNlen, M, chksm    : Byte;
  11.  begin
  12.     WriteLn; WriteLn( 'ISBN Verification v0.1, Greg Vigneault',#10);
  13.  
  14.     if ( ParamCount <> 1 ) then begin   { we want just 1 input parm }
  15.         WriteLn( 'Syntax: ISBN <ISBN#>',#7 );
  16.         Halt(1);
  17.     end;
  18.     ISBNstr := ParamStr(1);                     { get ISBN# String  }
  19.     Write( 'Checking ISBN# ', ISBNstr );
  20.     { eliminate any non-digit Characters from the ISBN String...    }
  21.     ISBNlen := 0;
  22.     For loopc := 1 to orD( ISBNstr[0] ) do
  23.         if ( ISBNstr[ loopc ] in ['0'..'9'] ) then begin
  24.             inC( ISBNlen );
  25.             ISBNstr[ ISBNlen ] := ISBNstr[ loopc ];
  26.         end;
  27.     { an 'X' at the end of the ISBN affects the result              }
  28.     if ( ISBNstr[ orD( ISBNstr[0] ) ] in ['X','x'] )
  29.         then M := 10
  30.         else M := orD( ISBNstr[ ISBNlen ] ) - 48;
  31.     ISBNstr[0] := CHR( ISBNlen );           { new ISBN str length   }
  32.     chksm := 0;
  33.     For loopc := 1 to ISBNlen-1 do
  34.         inC( chksm, ( orD( ISBNstr[ loopc ] ) - 48 ) * loopc );
  35.     Write( ' <--- ' );
  36.     if ( ( chksm MOD 11 ) = M )
  37.         then WriteLn( 'Okay' )
  38.         else WriteLn( 'ERRor!',#7 );
  39.  end {VerifyISBN}.
  40. (********************************************************************)
  41.